<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;


class Organization extends Model
{
    use HasFactory;
    protected $guarded = [];
    protected $appends = ['position'];

    public function OrganizationType(){        
        return $this->hasOne(OrganizationType::class,'id','type_id');
    }

    public function getPositionAttribute(){
        return [$this->lng,$this->lat];
    }

    public function getImageListAttribute(){
        return $this->attributes['image_list'] ? json_decode($this->attributes['image_list']) : [];
    }
}
